//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Spreadsheet
{
    public class Scenarios: IOfficeXmlSerializable
    {
        readonly List<Scenario> _scenarios = new List<Scenario>();
        private int? _current;
        private int? _show;
        private string _sqref;

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read("scenarios"))
            {
                _current = c.GetOptionalInteger("current");
                _show = c.GetOptionalInteger("show");
                _sqref = c.GetOptionalString("sqref");
                _scenarios.Clear();
                _scenarios.AddRange(c.ReadOptionalWhile<Scenario>("scenario"));
            }

        }

        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write("scenarios"))
            {
                c.SetOptionalInteger("current", _current);
                c.SetOptionalInteger("show", _show);
                c.SetOptionalString("sqref", _sqref);
                c.WriteElements(_scenarios);
            }
        }
    }
}